/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package clienttest;

import clienttest.common.ConnectManager;
import clienttest.common.PrintToPdf;
import clienttest.object.CreditCard;
import clienttest.object.ResultReponse;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.SimpleDateFormat;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.*;

/**
 *
 * @author lekhanhduy
 */
public class AcountBank extends javax.swing.JFrame {

    private CreditCard creditCard;
    private ConnectManager connectManager;
    private WindowAdapter windowAdapter;

    /**
     * Creates new form AcountBank
     */
    public AcountBank() {
        initComponents();
        this.setLocationRelativeTo(null);
        connectManager = new ConnectManager();
        jScPnHisTrans.setVisible(false);
        jTableHisTrans.setFillsViewportHeight(true);

        windowAdapter = new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent we) {
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        };
        this.addWindowListener(windowAdapter);

        //set so tien co the gui cho jcombobox 1
        jCbMoney1.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"500000", "1000000", "1500000", "2000000"}));
        jCbMoney2.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"500000", "1000000", "1500000", "2000000"}));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jBtnHisTrans = new javax.swing.JButton();
        jPnInfo = new javax.swing.JPanel();
        jLblInfo = new javax.swing.JLabel();
        jLblInfoUser = new javax.swing.JLabel();
        jScPnHisTrans = new javax.swing.JScrollPane();
        jTableHisTrans = new javax.swing.JTable();
        jDtChooFromDate = new com.toedter.calendar.JDateChooser();
        jDtChooToDate = new com.toedter.calendar.JDateChooser();
        jLblFromDate = new javax.swing.JLabel();
        jLblToDate = new javax.swing.JLabel();
        jPnAction = new javax.swing.JPanel();
        jTxtFAccountRev = new javax.swing.JTextField();
        jCbMoney2 = new javax.swing.JComboBox();
        jBtnTransfer = new javax.swing.JButton();
        jCbMoney1 = new javax.swing.JComboBox();
        jBtnWithDraw = new javax.swing.JButton();
        jLblAction = new javax.swing.JLabel();
        jBtnPrintfHis = new javax.swing.JButton();
        jMnBarAccount = new javax.swing.JMenuBar();
        jMnAccount = new javax.swing.JMenu();
        jMnItLogout = new javax.swing.JMenuItem();
        jMnItChangePass = new javax.swing.JMenuItem();
        jMnIntro = new javax.swing.JMenu();
        jMnItTour = new javax.swing.JMenuItem();
        jMnItAuthor = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jBtnHisTrans.setLabel("Lịch sử giao dịch");
        jBtnHisTrans.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnHisTransActionPerformed(evt);
            }
        });
        getContentPane().add(jBtnHisTrans, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 230, -1, 28));

        jPnInfo.setBackground(new java.awt.Color(204, 204, 204));
        jPnInfo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102), 2));

        jLblInfo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLblInfo.setText("Thông tin tài khoản");

        jLblInfoUser.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLblInfoUser.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLblInfoUser.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        javax.swing.GroupLayout jPnInfoLayout = new javax.swing.GroupLayout(jPnInfo);
        jPnInfo.setLayout(jPnInfoLayout);
        jPnInfoLayout.setHorizontalGroup(
            jPnInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnInfoLayout.createSequentialGroup()
                .addGroup(jPnInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPnInfoLayout.createSequentialGroup()
                        .addGap(112, 112, 112)
                        .addComponent(jLblInfo))
                    .addGroup(jPnInfoLayout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addComponent(jLblInfoUser, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(40, Short.MAX_VALUE))
        );
        jPnInfoLayout.setVerticalGroup(
            jPnInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnInfoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLblInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLblInfoUser, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE))
        );

        jLblInfoUser.getAccessibleContext().setAccessibleName("lblInfoAccount");

        getContentPane().add(jPnInfo, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 20, -1, 200));

        jScPnHisTrans.setBorder(null);

        jTableHisTrans.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102)));
        jTableHisTrans.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScPnHisTrans.setViewportView(jTableHisTrans);

        getContentPane().add(jScPnHisTrans, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 260, 720, 230));
        getContentPane().add(jDtChooFromDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 230, -1, 30));
        getContentPane().add(jDtChooToDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 230, -1, 28));

        jLblFromDate.setText("Từ ngày : ");
        getContentPane().add(jLblFromDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 230, -1, 28));

        jLblToDate.setText("Đến ngày : ");
        getContentPane().add(jLblToDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 230, -1, 28));

        jPnAction.setBackground(new java.awt.Color(204, 204, 204));
        jPnAction.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102), 2));

        jTxtFAccountRev.setToolTipText("Nhập số tài khoản hoặc số chứng minh thư người nhận");

        jCbMoney2.setEditable(true);
        jCbMoney2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jBtnTransfer.setText("Chuyển khoản");
        jBtnTransfer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnTransferActionPerformed(evt);
            }
        });

        jCbMoney1.setEditable(true);
        jCbMoney1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jCbMoney1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCbMoney1ActionPerformed(evt);
            }
        });

        jBtnWithDraw.setLabel("Rút tiền");
        jBtnWithDraw.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnWithDrawActionPerformed(evt);
            }
        });

        jLblAction.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLblAction.setText("Rút tiền/Chuyển khoản");

        javax.swing.GroupLayout jPnActionLayout = new javax.swing.GroupLayout(jPnAction);
        jPnAction.setLayout(jPnActionLayout);
        jPnActionLayout.setHorizontalGroup(
            jPnActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnActionLayout.createSequentialGroup()
                .addGroup(jPnActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPnActionLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPnActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPnActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTxtFAccountRev, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jCbMoney2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jCbMoney1, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPnActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jBtnTransfer, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                            .addComponent(jBtnWithDraw, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(jPnActionLayout.createSequentialGroup()
                        .addGap(88, 88, 88)
                        .addComponent(jLblAction)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPnActionLayout.setVerticalGroup(
            jPnActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnActionLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLblAction)
                .addGroup(jPnActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPnActionLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jBtnTransfer, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(43, 43, 43))
                    .addGroup(jPnActionLayout.createSequentialGroup()
                        .addGap(15, 15, 15)
                        .addGroup(jPnActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jCbMoney1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jBtnWithDraw, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(27, 27, 27)
                        .addComponent(jCbMoney2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jTxtFAccountRev, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(26, 26, 26))))
        );

        getContentPane().add(jPnAction, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 20, -1, -1));

        jBtnPrintfHis.setText("In lịch sử");
        jBtnPrintfHis.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnPrintfHisActionPerformed(evt);
            }
        });
        getContentPane().add(jBtnPrintfHis, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 230, 100, 28));

        jMnAccount.setText("Tài khoản");

        jMnItLogout.setText("Đăng xuất");
        jMnItLogout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMnItLogoutActionPerformed(evt);
            }
        });
        jMnAccount.add(jMnItLogout);

        jMnItChangePass.setText("Đổi mật khẩu");
        jMnItChangePass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMnItChangePassActionPerformed(evt);
            }
        });
        jMnAccount.add(jMnItChangePass);

        jMnBarAccount.add(jMnAccount);

        jMnIntro.setText("Giới thiệu");

        jMnItTour.setText("Hướng dẫn ");
        jMnIntro.add(jMnItTour);

        jMnItAuthor.setText("Tác giả");
        jMnItAuthor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMnItAuthorActionPerformed(evt);
            }
        });
        jMnIntro.add(jMnItAuthor);

        jMnBarAccount.add(jMnIntro);

        setJMenuBar(jMnBarAccount);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jCbMoney1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCbMoney1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCbMoney1ActionPerformed

    private void jBtnTransferActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnTransferActionPerformed
        // TODO add your handling code here:
        if (CheckInputMoney(jCbMoney2)) {
            double input = Double.valueOf(jCbMoney2.getSelectedItem().toString());
            String user_rev = jTxtFAccountRev.getText().toString();
            if (user_rev.equals("")) {
                JOptionPane.showMessageDialog(this,
                        "Tài khoản nhận không được trống!",
                        "Lỗi tài khoản nhận!",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
            if (user_rev.equals(creditCard.getAccountCode()) || user_rev.equals(creditCard.getIdentityCardNumber())) {
                JOptionPane.showMessageDialog(this,
                        "Không thể chuyển cho chính mình!",
                        "Lỗi tài khoản nhận!",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
            ResultReponse result = connectManager.check_transfers(user_rev);
            if (result != null) {
                if (result.isSuccess()) {
                    ResultReponse resultTemp = connectManager.transfersCreditCard(creditCard.getAccountCode(), user_rev, input);
                    if (resultTemp != null) {
                        if (resultTemp.isSuccess()) {
                            JOptionPane.showMessageDialog(this,
                                    resultTemp.getNote(),
                                    "Chuyển tiền thành công!",
                                    JOptionPane.INFORMATION_MESSAGE);
                            DisplayInfo(creditCard.getAccountCode());
                            if (jScPnHisTrans.isShowing()) {
                                displayHistory();
                            }
                        } else {
                            JOptionPane.showMessageDialog(this,
                                    resultTemp.getNote(),
                                    "Lỗi chuyển tiền!",
                                    JOptionPane.ERROR_MESSAGE);
                        }
                    }
                } else {
                    JOptionPane.showMessageDialog(this,
                            result.getNote(),
                            "Lỗi tài khoản nhận!",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    }//GEN-LAST:event_jBtnTransferActionPerformed

    /*
     * Phương thức gửi tiền
     */
    private void jBtnWithDrawActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnWithDrawActionPerformed
        if (CheckInputMoney(jCbMoney1)) {
            double input = Double.valueOf(jCbMoney1.getSelectedItem().toString());
            ResultReponse result = connectManager.sentWithDrawMoney(creditCard.getAccountCode(), "withdraw", input);
            if (result != null) {
                if (result.isSuccess()) {
                    JOptionPane.showMessageDialog(this,
                            result.getNote(),
                            "Rút tiền thành công!",
                            JOptionPane.INFORMATION_MESSAGE);
                    DisplayInfo(creditCard.getAccountCode());
                    if (jScPnHisTrans.isShowing()) {
                        displayHistory();
                    }
                } else {
                    JOptionPane.showMessageDialog(this,
                            result.getNote(),
                            "Rút tiền lỗi!",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    }//GEN-LAST:event_jBtnWithDrawActionPerformed

    private void jBtnHisTransActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnHisTransActionPerformed
        // TODO add your handling code here:
        if (creditCard != null) {    
                displayHistory();
        }
    }//GEN-LAST:event_jBtnHisTransActionPerformed

    private void jMnItLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMnItLogoutActionPerformed
        // TODO add your handling code here:
        Login login = new Login(new AcountBank());
        login.setVisible(true);
        login.show();
        this.dispose();
    }//GEN-LAST:event_jMnItLogoutActionPerformed

    private void jMnItChangePassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMnItChangePassActionPerformed
        ChangePassWord changePass = new ChangePassWord();
        changePass.changePass(creditCard);
        changePass.setVisible(true);
        changePass.show();
    }//GEN-LAST:event_jMnItChangePassActionPerformed

    private void jMnItAuthorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMnItAuthorActionPerformed
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(this,
                "<html>Họ và tên : Lê Khánh Duy <br> SHSV : 20090472 <br> Lớp : Kĩ thuật máy tính và truyền thông 1 K54</html>",
                "Thông tin tác giả!",
                JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jMnItAuthorActionPerformed

    private void jBtnPrintfHisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnPrintfHisActionPerformed
        // TODO add your handling code here:
        if (jTableHisTrans.getRowCount() > 0) {
            int selection = JOptionPane.showConfirmDialog(
                    this, "Bạn có muốn in lịch sử không", "Hãy lựa chọn : ", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
            if (selection == JOptionPane.OK_OPTION) {
                String[] head = {"Loại giao dịch", "Người nhận/gửi", "Ngày giao dịch", "Giờ giao dịch", "Số tiền"};
                PrintToPdf print = new PrintToPdf(jTableHisTrans, head, creditCard.getFirstName() + " " + creditCard.getLastName());
                SimpleDateFormat dt = new SimpleDateFormat("dd-MM-yyyy");
                String dateFrom = dt.format(jDtChooFromDate.getDate());
                String dateTo = dt.format(jDtChooToDate.getDate());
                print.printfPDF(dateFrom, dateTo);
            } else if (selection == JOptionPane.CANCEL_OPTION) {
            }
        } else {
            JOptionPane.showMessageDialog(this,
                    "Chưa có dữ liệu để in",
                    "Lỗi in dữ liệu!",
                    JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jBtnPrintfHisActionPerformed

    public void DisplayInfo(String accountName) {
        creditCard = connectManager.getCreditCardOfUser(accountName);
        if (creditCard != null) {
            jLblInfoUser.setText("<html>" + creditCard.toString().replace("\n", "<br>") + "</html>");
        }
    }

    public void DisplayInfo(CreditCard credit) {
        creditCard = credit;
        if (creditCard != null) {
            jLblInfoUser.setText("<html>" + creditCard.toString().replace("\n", "<br>") + "</html>");
        }
    }

    public void displayHistory() {
        SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd");
        String dateFrom = dt.format(jDtChooFromDate.getDate());
        String dateTo = dt.format(jDtChooToDate.getDate());
        Object[][] data = connectManager.getAllHistoryCreditCard(creditCard.getAccountCode(), dateFrom, dateTo);
        jTableHisTrans.setModel(new javax.swing.table.DefaultTableModel(
                data,
                new String[]{
                    "Loại giao dịch", "Người nhận/gửi", "Ngày giao dịch", "Giờ giao dịch", "Số tiền"
                }));
        jScPnHisTrans.setVisible(true);
        DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
        rightRenderer.setHorizontalAlignment(JLabel.RIGHT);
        jTableHisTrans.getColumnModel().getColumn(4).setCellRenderer(rightRenderer);
        validate();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AcountBank.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AcountBank.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AcountBank.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AcountBank.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new AcountBank().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBtnHisTrans;
    private javax.swing.JButton jBtnPrintfHis;
    private javax.swing.JButton jBtnTransfer;
    private javax.swing.JButton jBtnWithDraw;
    private javax.swing.JComboBox jCbMoney1;
    private javax.swing.JComboBox jCbMoney2;
    private com.toedter.calendar.JDateChooser jDtChooFromDate;
    private com.toedter.calendar.JDateChooser jDtChooToDate;
    private javax.swing.JLabel jLblAction;
    private javax.swing.JLabel jLblFromDate;
    private javax.swing.JLabel jLblInfo;
    private javax.swing.JLabel jLblInfoUser;
    private javax.swing.JLabel jLblToDate;
    private javax.swing.JMenu jMnAccount;
    private javax.swing.JMenuBar jMnBarAccount;
    private javax.swing.JMenu jMnIntro;
    private javax.swing.JMenuItem jMnItAuthor;
    private javax.swing.JMenuItem jMnItChangePass;
    private javax.swing.JMenuItem jMnItLogout;
    private javax.swing.JMenuItem jMnItTour;
    private javax.swing.JPanel jPnAction;
    private javax.swing.JPanel jPnInfo;
    private javax.swing.JScrollPane jScPnHisTrans;
    private javax.swing.JTable jTableHisTrans;
    private javax.swing.JTextField jTxtFAccountRev;
    // End of variables declaration//GEN-END:variables

    public boolean CheckInputMoney(JComboBox jcombobox) {
        boolean result = false;
        if (creditCard != null) {
            double input = 0;
            try {
                input = Double.valueOf(jcombobox.getSelectedItem().toString());
                if (!creditCard.checkMonney(input)) {
                    JOptionPane.showMessageDialog(this,
                            "Số tiền phải lớn hơn 0 và là bội số của 10000 VND!",
                            "Lỗi đầu vào!",
                            JOptionPane.ERROR_MESSAGE);
                    jcombobox.setSelectedIndex(0);
                } else {
                    result = true;
                }
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this,
                        "Số tiền phải lớn hơn 0 và là bội số của 10000 VND!",
                        "Lỗi đầu vào!",
                        JOptionPane.ERROR_MESSAGE);
                jcombobox.setSelectedIndex(0);
            }
        }
        return result;
    }
}
